Re: BUG #16743: psql doesn't show whole expression in stored column

Поиск
Список
Период
Сортировка
От David Turoň
Тема Re: BUG #16743: psql doesn't show whole expression in stored column
Дата
Msg-id EWs.5rNI.4xkN1D}JwHK.1VlWlO@seznam.cz
обсуждение исходный текст
Ответ на BUG #16743: psql doesn't show whole expression in stored column  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
Yes ist little bit confusing with truncate only part and leave stored. Maybe substring to first 125 and append at least '...' or some switch in psql '\pset cut_row_length on' or something similar.

postgres@pgdist:test=# SELECT a.attname,
  pg_catalog.format_type(a.atttypid, a.atttypmod),
  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid, true) for 125)||'...'
   FROM pg_catalog.pg_attrdef d
   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),
  a.attnotnull,
  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t
   WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation,
  a.attidentity,
  a.attgenerated
FROM pg_catalog.pg_attribute a
WHERE a.attrelid = '896567' AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum;

-[ RECORD 5 ]+---------------------------------------------------------------------------------------------------------------------------------
attname      | ts_vector
format_type  | tsvector
?column?     | ((setweight(to_tsvector('simple'::regconfig, COALESCE(a, ''::text)), 'A'::"char") || setweight(to_tsvector('simple'::regconfi...
attnotnull   | f
attcollation | <NULL>
attidentity  | 
attgenerated | s

I am using pager, so for me fixed row/column lenght isn't priority.  

regards, David T.

---------- Původní e-mail ----------
Od: Tom Lane <tgl@sss.pgh.pa.us>
Komu: Bruce Momjian <bruce@momjian.us>
Datum: 24. 11. 2020 17:26:07
Předmět: Re: BUG #16743: psql doesn't show whole expression in stored column
Bruce Momjian <bruce@momjian.us> writes:
> On Tue, Nov 24, 2020 at 10:46:57AM -0500, Tom Lane wrote:
>> Maybe we should decide that completeness is more important than keeping
>> the line to some arbitrary width. But it's operating as designed.

> I think I am fine with the current behavior.

It's less great in the context of a GENERATED column. As things stand,
the psql-side code wraps the truncated result into some more syntax:

else if (generated[0] == ATTRIBUTE_GENERATED_STORED)
default_str = psprintf("generated always as (%s) stored", PQgetvalue(res, i, attrdef_col));
else
/* (note: above we cut off the 'default' string at 128) */
default_str = PQgetvalue(res, i, attrdef_col);

which seems distinctly more confusing than just truncating the result.
So maybe there's justification here for revisiting that ancient decision.

One could also imagine not appending ") stored" if the attrdef value
appears to have been truncated --- although encoding-conversion effects
would make it hard to tell that for sure. Perhaps we'd be better off
to move the truncation logic to the psql side?

Another thing here, which is undeniably a bug, is that that psprintf
result is promptly leaked.

regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Peter Smith
Дата:
Сообщение: Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: BUG #16743: psql doesn't show whole expression in stored column